package file;

import java.io.*;

public class BufferedDemo2 {
    public static void main(String[] args) {
        FileOutputStream fos=null;
        FileInputStream fis=null;
        BufferedOutputStream bos=null;
        BufferedInputStream bis=null;
        try {
            fos=new FileOutputStream("thread\\fileOutput.txt",true);
            fis=new FileInputStream("thread\\fileOutput.txt");
            bos=new BufferedOutputStream(fos);
            bis=new BufferedInputStream(fis);
            long startTime=System.currentTimeMillis();
            bos.write(50);
            bos.write('a');
            bos.flush();
            System.out.print(bis.read());
            System.out.println();
            System.out.print((char)bis.read());
            System.out.println();
            long endTime=System.currentTimeMillis();
            System.out.println(endTime-startTime);
            fos.close();
            fis.close();
            bos.close();
            bis.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
